{include file="common/forum_head"}
<div class="fly-panel fly-column">
  <div class="layui-container">
    <ul class="layui-clear cate-list">

      <input type="hidden" id="select-cate" value="{$cateid}">
      <li class="select-cate layui-hide-xs {if($cateid==0)}layui-this{/if} " data-attr="0"><a href="{:url('/index/forum')}">首页</a></li>  <!--layui-this-->
      {foreach $cate_list as $k=>$v}
      <li class="select-cate {if($cateid==$v['id'])}layui-this{/if}" data-attr="{$v.id}">
        <a  href="javascript:;">{$v.name} <!-- <span class="layui-badge-dot"></span>--> </a>
      </li>
      {/foreach}
      <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li> 
      
      <!-- 用户登入后显示 -->
      {if(!empty($center_info ))}
      <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('/index/center/my_note')}">我发表的贴</a></li>
      <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('/index/center/my_note')}#collection">我收藏的贴</a></li>
      {/if}
    </ul> 
    
    <div class="fly-column-right layui-hide-xs">
      <span class="fly-search"><i class="layui-icon"></i></span>
      <a href="{:url('/index/forum/addnote')}" class="layui-btn checkCenter">发表新帖</a>
    </div>
    <div class="layui-hide-sm layui-show-xs-block" style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
      <a href="{:url('/index/forum/addnote')}" class="layui-btn">发表新帖</a>
    </div>
  </div>
</div>

<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md8">
      <div class="fly-panel">
        <div class="fly-panel-title fly-filter">
          <a>置顶</a>
          <a href="javascript:;" class="{if(!$is_signin)} layui-hide-sm  {/if} layui-show-xs-block fly-right checkCenter" id="LAY_signin" style="color: #FF5722;">去签到</a>
        </div>
        <ul class="fly-list">
          {foreach $note_top_list as $k=>$v}
          <li>
            <a href="{:url('/index/center/home')}?id={$v.center_id}" class="fly-avatar">
              <img src="{$v.thumb}" alt="{$v.username}">
            </a>
            <h2>
              <a class="layui-badge">{$v.name}</a>
              <a href="{:url('/index/forum/noteDetail')}?id={$v.id}">{$v.title}</a>
            </h2>
            <div class="fly-list-info">
              <a href="{:url('/index/center/home')}?id={$v.center_id}" link>
                <cite>{$v.username}</cite>
                <i class="iconfont icon-renzheng" title="认证信息：XXX"></i>
                <i class="layui-badge fly-badge-vip">VIP3</i>
              </a>
              <span>{$v.update_time_con}</span>

              <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i class="iconfont icon-jifen"></i> {$v.credit}</span>
              {if($v['is_end']==1)}
              <span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
               {/if}
              <span class="fly-list-nums">
                <i class="iconfont icon-pinglun1" title="回答"></i> {$v.comment_num}
              </span>

            </div>
            <div class="fly-list-badge">
              {if $v['is_top']==1}
              <span class="layui-badge layui-bg-black">置顶</span>
              {/if}
              {if $v['is_good']==1}
              <span class="layui-badge layui-bg-red">精帖</span>
              {/if}
            </div>
          </li>
          {/foreach}

        </ul>
      </div>

      <div class="fly-panel" style="margin-bottom: 0;">
        <input type="hidden" id="select-type" value="0">
        <input type="hidden" id="select-content" value="1">
        <div class="fly-panel-title fly-filter">
          <a href="javascript:;" data-attr="0" class="select-type {if($type==0)}layui-this{/if}">综合</a>
          <span class="fly-mid"></span>
          <a href="javascript:;" data-attr="1" class="select-type {if($type==1)}layui-this{/if}">未结</a>
          <span class="fly-mid"></span>
          <a href="javascript:;" data-attr="2" class="select-type {if($type==2)}layui-this{/if}">已结</a>
          <span class="fly-mid"></span>
          <a href="javascript:;" data-attr="3" class="select-type {if($type==3)}layui-this{/if}">精华</a>
          <span class="fly-filter-right layui-hide-xs">
            <a href="javascript:;"  data-attr="1" class="select-content {if($content==1)}layui-this{/if}">按最新</a>
            <span class="fly-mid"></span>
            <a href="javascript:;"  data-attr="2" class="select-content {if($content==2)}layui-this{/if}">按热议</a>
          </span>
        </div>

        <ul class="fly-list note-list">
          {foreach $note_list as $k=>$v}
          <li>
              <a href="{:url('/index/center/home')}?id={$v.center_id}" class="fly-avatar">
                  <img src="{$v.thumb}" alt="{$v.username}">
              </a>
            <h2>
              <a class="layui-badge">{$v.name}</a>
              <a href="{:url('/index/forum/noteDetail')}?id={$v.id}">{$v.title}</a>
            </h2>
            <div class="fly-list-info">
              <a href="{:url('/index/center/home')}?id={$v.center_id}" link>
                <cite>{$v.username}</cite>

                <i class="iconfont icon-renzheng" title="认证信息：XXX"></i>
                <i class="layui-badge fly-badge-vip">VIP3</i>

              </a>
              <span>{$v.update_time_con}</span>

              <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i class="iconfont icon-jifen"></i> {$v.credit}</span>
                {if($v['is_end']==1)}
              <span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
                {/if}
              <span class="fly-list-nums">
                <i class="iconfont icon-pinglun1" title="回答"></i>{$v.comment_num}
              </span>
            </div>
            <div class="fly-list-badge">
                {if($v['is_good']==1)}
              <span class="layui-badge layui-bg-red">精帖</span>
                {/if}
            </div>
          </li>
          {/foreach}
        </ul>

        <div id="note-list" style="text-align: center"></div>
      </div>

    </div>

    <div class="layui-col-md4">

      <div class="fly-panel">
        <h3 class="fly-panel-title">温馨通道</h3>
        <ul class="fly-panel-main fly-list-static">
          <li>
            <a href="{:url('/index/forum')}" target="_blank">社区首页</a>
          </li>
          <!--<li>-->
            <!--<a href="{:url('/index/forum/case')}" target="_blank">案例页面</a>-->
          <!--</li>-->
        </ul>
      </div>

<!--
      <div class="fly-panel fly-signin">
        <div class="fly-panel-title">
          签到
          <i class="fly-mid"></i> 
          <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
          <i class="fly-mid"></i> 
          <a href="javascript:;" class="fly-link" id="LAY_signinTop">活跃榜<span class="layui-badge-dot"></span></a>
          {if(!empty($center_info)) }
          <span class="fly-signin-days">已连续签到<cite>{$center_info.continue_sign_num}</cite>天</span>
          {/if}
        </div>
        <div class="fly-panel-main fly-signin-main">
          {if(!empty($center_info)) }
            {if($is_signin)}
            <button class="layui-btn layui-btn-danger checkCenter" id="LAY_signin">今日签到</button>
            <span>可获得<cite>5</cite>飞吻</span>
            {else}

            <button class="layui-btn layui-btn-disabled">今日已签到</button>
            <span>获得了<cite>20</cite>飞吻</span>
            {/if}
          {else}
            <span><cite>请登陆</cite></span>
          {/if}
        </div>
      </div>
      -->

      <div class="fly-panel fly-signin">
        <div class="fly-panel-title">
          签到
          <i class="fly-mid"></i>
          <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
          <i class="fly-mid"></i>
          <a href="javascript:;" class="fly-link" id="LAY_signinTop">活跃榜<span class="layui-badge-dot"></span></a>
          {if(!empty($center_info))}
          <span class="fly-signin-days"></span>
          {/if}
        </div>
        <div class="fly-panel-main fly-signin-main"></div>
      </div>


      <div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
        <h3 class="fly-panel-title">回贴周榜</h3>
        <dl>
          <!--<i class="layui-icon fly-loading">&#xe63d;</i>-->
          <!--<dd>-->
            <!--<a href="user/home.html">-->
              <!--<img src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>-->
            <!--</a>-->
          <!--</dd>-->
          <!--<dd>-->
            <!--<a href="user/home.html">-->
              <!--<img src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>-->
            <!--</a>-->
          <!--</dd>-->
          <!--<dd>-->
            <!--<a href="user/home.html">-->
              <!--<img src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>-->
            <!--</a>-->
          <!--</dd>-->
          <!--<dd>-->
            <!--<a href="user/home.html">-->
              <!--<img src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>-->
            <!--</a>-->
          <!--</dd>-->

        </dl>
      </div>

      <dl class="fly-panel fly-list-one" id="LAY_noteRank">
        <!--<dt class="fly-panel-title">本周热议</dt>-->

        <!--<dd>-->
          <!--<a href="jie/detail.html">基于 layui 的极简社区页面模版</a>-->
          <!--<span><i class="iconfont icon-pinglun1"></i> 16</span>-->
        <!--</dd>-->
        <!--<dd>-->
          <!--<a href="jie/detail.html">基于 layui 的极简社区页面模版</a>-->
          <!--<span><i class="iconfont icon-pinglun1"></i> 16</span>-->
        <!--</dd>-->
        <!--<dd>-->
          <!--<a href="jie/detail.html">基于 layui 的极简社区页面模版</a>-->
          <!--<span><i class="iconfont icon-pinglun1"></i> 16</span>-->
        <!--</dd>-->
        <!--<dd>-->
          <!--<a href="jie/detail.html">基于 layui 的极简社区页面模版</a>-->
          <!--<span><i class="iconfont icon-pinglun1"></i> 16</span>-->
        <!--</dd>-->

        <!-- 无数据时 -->
        <!--
        <div class="fly-none">没有相关数据</div>
        -->
      </dl>

      <div class="fly-panel">
        <div class="fly-panel-title">
          广告区域
        </div>
        <div class="fly-panel-main">
          <a href="http://www.webplatform.com/index/forum/index.html#" target="_blank" class="fly-zanzhu" time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">
            广告位置 请加QQ群933613329
          </a>
        </div>
      </div>
      
      <div class="fly-panel fly-link">
        <h3 class="fly-panel-title">友情链接（可与管理员联系 请加QQ群933613329）</h3>
        <dl class="fly-panel-main">
          <dd><a href="http://www.webplatform.com/index/forum/index.html#" target="_blank">webplatform</a><dd>
          <!--<dd><a href="http://layim.layui.com/" target="_blank">WebIM</a><dd>-->
          <!--<dd><a href="http://layer.layui.com/" target="_blank">layer</a><dd>-->
          <!--<dd><a href="http://www.layui.com/laydate/" target="_blank">layDate</a><dd>-->
          <!--<dd><a href="mailto:xianxin@layui-inc.com?subject=%E7%94%B3%E8%AF%B7Fly%E7%A4%BE%E5%8C%BA%E5%8F%8B%E9%93%BE" class="fly-link">申请友链</a><dd>-->
        </dl>
      </div>

    </div>
  </div>
</div>

<script>
$(function(){

    // $('#LAY_signin').click(function(){
    //     $.ajax({
    //         type: "POST",
    //         url: "{:url('center/signin')}",
    //         dataType:'json',
    //         data: {},
    //         success: function(data){
    //             layer.msg(data.msg);
    //         }
    //     });
    // });


    layui.use('laypage', function(){
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'note-list' //ID
            ,count: {$note_list_count} //数据总数，从服务端得到
            ,limit: {$limit}
            ,prev: '<'
            ,next: '>'
            ,jump: function(obj, first){
                //obj包含了当前分页的所有参数，比如：
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数
                var cateid = $('#select-cate').val();
                var type = $('#select-type').val();
                var content = $('#select-content').val();
                if(!first) {
                    $.ajax({
                        type: "POST",
                        url: "{:url('forum/notePage')}",
                        dataType:'json',
                        data: {
                            curr:obj.curr,
                            limit:obj.limit,
                            cateid:cateid,
                            type:type,
                            content:content
                        },
                        success: function(data){
                            console.log(data);
                            $('.note-list').html('');
                            var htmls = '';
                            for(var i=0;i<data.length;i++){
                                htmls += '<li>';
                                htmls += '<a href="{:url(\'/index/center/home\')}?id='+data[i].center_id+'" class="fly-avatar">';
                                htmls +='<img src=" '+data[i].thumb+' " alt=" '+data[i].username+' ">';
                                htmls +='</a>';
                                htmls +='<h2>';
                                htmls +='<a class="layui-badge"> '+data[i].name+' </a>';
                                htmls +='<a href="{:url(\'/index/forum/noteDetail\')}?id='+data[i].id+'">'+data[i].title+'</a>';
                                htmls +='</h2>';
                                htmls +='<div class="fly-list-info">';
                                htmls +='<a href="{:url(\'/index/center/home\')}?id='+data[i].center_id+'" link>';
                                htmls +='<cite>'+data[i].username+' </cite>';
                                htmls +='<i class="iconfont icon-renzheng" title="认证信息：XXX"></i>';
                                htmls +='<i class="layui-badge fly-badge-vip">VIP3</i>';
                                htmls +='</a>';
                                htmls +='<span>'+data[i].update_time_con+'</span>';
                                htmls +='<span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i class="iconfont icon-jifen"></i> '+data[i].credit+'</span>';
                                if(data[i].is_end == 1){
                                    htmls +='<span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>';
                                }
                                htmls +='<span class="fly-list-nums">';
                                htmls +='<i class="iconfont icon-pinglun1" title="回答"></i> '+data[i].comment_num;
                                htmls +='</span>';
                                htmls +='</div>';
                                htmls +='<div class="fly-list-badge">';
                                if(data[i].is_good == 1) {
                                    htmls += '<span class="layui-badge layui-bg-red">精帖</span>';
                                }
                                htmls +='</div>';
                                htmls +='</li>';
                            }


                            $('.note-list').html(htmls);

                        }
                    });
                }

            }
        });
    });

    $('.select-cate').click(function(){
        var attr = $(this).attr('data-attr');
        $('#select-cate').val(attr);
        $('.select-cate').removeClass('layui-this');
        $(this).addClass('layui-this');

        var content = $('#select-content').val();
        var type = $('#select-type').val();
        window.location.href = "{:url('/index/forum')}?cateid="+attr+"&type="+type+"&content="+content;
    })

    $('.select-type').click(function(){
        var attr = $(this).attr('data-attr');
        $('#select-type').val(attr);
        $('.select-type').removeClass('layui-this');
        $(this).addClass('layui-this');

        var cateid = $('#select-cate').val();
        var content = $('#select-content').val();
        window.location.href = "{:url('/index/forum')}?cateid="+cateid+"&type="+attr+"&content="+content;
    })

    $('.select-content').click(function(){
        var attr = $(this).attr('data-attr');
        $('#select-content').val(attr);
        $('.select-content').removeClass('layui-this');
        $(this).addClass('layui-this');

        var cateid = $('#select-cate').val();
        var type = $('#select-type').val();
        window.location.href = "{:url('/index/forum')}?cateid="+cateid+"&content="+attr+"&type="+type;
    })
})
layui.cache.page = '';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: '../res/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  version: "3.0.0"
  ,base: '__MODS__/' //这里实际使用时，建议改成绝对路径
}).extend({
  fly: 'index'
}).use('fly');
</script>

{include file="common/forum_foot"}